package dao

import (
	"fmt"
	__ "user-srv/basic/proto"
	"user-srv/handler/models"
)

// 勋章规则添加
func BadgeRulesAdd(in *__.BadgeRulesAddReq) (*models.BadgeRules, error) {
	var badgeRules models.BadgeRules

	badgeRules.Name = in.Name           //勋章名称
	badgeRules.Desc = in.Desc           //规则描述
	badgeRules.Condition = in.Condition //获取条件
	err := badgeRules.BadgeRulesAdd()
	if err != nil {
		return nil, fmt.Errorf("勋章规则添加失败")
	}

	return &badgeRules, nil
}

// 勋章规则详情
func BadgeRulesDetail(in *__.BadgeRulesDetailReq) (*models.BadgeRules, error) {
	var badgeRules models.BadgeRules
	err := badgeRules.GetBadgeRulesInfoById(int(in.Id))
	if err != nil {
		return nil, fmt.Errorf("勋章规则详情失败")
	}

	return &badgeRules, nil
}
